package com.experian.daas.litigation.rest;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import com.experian.daas.litigation.entity.Cart;
import com.experian.daas.litigation.service.CartService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@RestController
@Api("userController相关api")
public class LitigationRest {
	@Autowired
	private CartService cartService;
	
	@Autowired
    private RestTemplate restTemplate;
	
	@ApiOperation(value="获取购物车列表", notes="所有用户")
	@RequestMapping("/carts")
	public List<Cart> getCarts(){
		return cartService.getCarts();
	}
	
	@ApiOperation(value="获取用户列表", notes="获取api rest调用")
    @ApiImplicitParam(name = "user", value = "用户详细实体user", required = true, dataType = "User")
	@RequestMapping("/getUser")
	public String getUser(){
		ResponseEntity<String> entity = restTemplate.getForEntity("http://localhost:9092/page", String.class);
		return entity.getBody();
	}
	
	

}
